/**
 * ClassName: RecursionDemo
 * Package: PACKAGE_NAME
 * Description:
 *
 * @Author harkjeans
 * @Create 2025/9/1 20:28
 * @Version 1.0
 */
public class RecursionDemo {
    public static void main(String[] args) {
        RecursionDemo demo = new RecursionDemo();
        int num = 5;
        int sum = demo.getSum(num);
        System.out.println(sum);
    }

    public int getSum(int num){
        if (num == 1){
            return 1;
        }else{
            return num + getSum(num - 1);
        }

    }
}
